﻿<!DOCTYPE html>
<html>
<head>
    <title>{$platform.name}</title>
    <link href="/static/css/framework-font.css" rel="stylesheet"/>
    <script src="/static/js/jquery-2.1.1.js"></script>
    <script src="/static/bootstrap/js/bootstrap.js"></script>
    <link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>

    <script src="/static/js/jquery.cookie.js"></script>
    <link href="/static/css/framework-theme.css" rel="stylesheet"/>
    <script src="/static/js/framework-ui.js"></script>
    <script src="/static/js/framework-clientdata.js"></script>

    <!--弹框js-->
    <script src="/static/js/yii.js"></script>

    <!--引用layui弹框插件-->
    <script src="/static/layui/layui.all.js"></script>
    <script src="/static/layui/layui.js"></script>
    <link href="/static/layui/css/layui.css" rel="stylesheet"/>
    <script src="/static/layui/lay/modules/layer.js"></script>

        {if condition="$swidthStyle eq 0"}
    <link href="/static/css/pattern/public.css" rel="stylesheet"/>
    {else/}
    <link href="/static/css/default/public.css" rel="stylesheet"/>
    {/if}
</head>
<body>
<style>
    .status{font-size: 12px;color: #fff;padding: 3px 6px;border-radius: 6px;}
    .status3{background-color:#f0ad4e}
    .status1{background-color:#1edc20}
    .status2{background-color:#ff0800}
</style>

<div class="newtest">

    <div class="container new_serach">

        <span> 景区名称：</span>
        <div class="layui-inline layui-form">
            <select name="colony_id" lay-filter="colony_id" lay-search="">
                <option value="0" > 请选择 </option>
                <option value="-1" {if condition="$colony_id eq -1"} selected {/if}> 平台 </option>
                {volist name="community" id="vo"}
                <option value="{$vo.id}" {if condition="$colony_id eq $vo['id']"} selected {/if}> {$vo.name} </option>
                {/volist}
            </select>
        </div>

        <span> 关键字：</span>
        <div class="layui-inline">
            <input class="form-control serach_key" name="keyword" value="{$keyword}" type="text">
        </div>
        <span> 状态：</span>
        <div class="layui-inline layui-form"  style="width:80px;">
            <select name="status" lay-filter="status">
                <option value="0" {if condition="$status eq 0"} selected {/if}>全部</option>
                <option value="1" {if condition="$status eq 1"} selected {/if}>已发布</option>
                <option value="3" {if condition="$status eq 3"} selected {/if}>已保存</option>
            </select>
        </div>
        <button class="layui-btn layui-btn-sm" data-type="reload">搜索</button>
    </div>

    <div class="new_main">
        <table class="layui-hide" id="demo" lay-filter="demo"></table>
        <script type="text/html" id="barDemo">
        <a class="btn-sm btn-primary" href="{:Url('Answer/addAnswer')}?id={{d.id}}">回复</a>
        <a class="btn-sm btn-danger" lay-event="del">删除</a>
        </script>
        <script type="text/html" id="toolbarDemo">
            <div class="layui-btn-container">
            <a class="layui-btn layui-btn-sm" href="{:URL('community/Answer/addAnswer')}" >添加信息</a>
            <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="getCheckLength">批量删除</button>
            </div>
        </script>
    </div>
</div>

</body>
<script src="/static/js/index.js"></script>
<script src="/static/js/indextab.js"></script>
<script src="/static/js/pace.min.js"></script>
<script>
    var modal = new yii.modal();

    layui.use(['form', 'jquery', 'layer', 'laydate','table'], function () { //独立版的layer无需执行这一句
        var $ = layui.jquery, layer = layui.layer;
        var form = layui.form;
        var laydate = layui.laydate;
        var table = layui.table //表格
        //日期范围
        laydate.render({
            elem: '#test6'
            , range: true
        });
        var status = 0;
        form.on('select(status)',function (data) {
            status = data.value;
        })
        var colony_id = 0;
        form.on('select(colony_id)',function (data) {
            colony_id = data.value;
        })

        var url = "{:URL('community/answer/index')}";
        //搜索操作
        $('.layui-btn').click(function () {
            var keyword = $('input[name="keyword"]').val();
            var where = {keyword:keyword,status:status,colony_id:colony_id};
            search(table,url,where)
        });

        //列表
        var where = {type:'list'};
        var title = "广告列表";
        var cols = [[
            {type: 'checkbox', fixed: 'left'}
            ,{field: 'id', title: 'ID',sort: true, fixed: 'left',width:80, align:'center'}
            ,{field: 'title', title: '问题', align:'center'}
            ,{field: 'addtime', title: '发布时间', align:'center'}
            ,{field: 'updatetime', title: '回复时间', align:'center'}
            ,{field: 'add_name', title: '发布者', align:'center'}
            ,{field: 'update_name', title: '回复人', align:'center'}
            ,{field: 'status', title: '状态',align:'center'}
            ,{fixed: 'right',title: '操作', width:300, align:'center', toolbar: '#barDemo'}
        ]];
        showlist(table,url,where,title,cols);
            //监听行工具事件
        table.on('tool(demo)', function(obj) {
            var id = obj.data.id;
            switch (obj.event) {
                case 'del':
                    layer.confirm('是否确定操作?', function (index) {
                        let url="{:URL('community/answer/delAnswer')}";
                        let data = {id:id};
                        publicDel(table,url,data,obj,index);
                    });
                    break;
            }
        });

        //头工具栏事件
        table.on('toolbar(demo)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id);
            switch(obj.event){
                case 'getCheckLength':
                    var data = checkStatus.data;
                    var id=[];
                    for (var i = 0; i < data.length; i++) {
                        id[i] = data[i].id;
                    }
                    if(id.length==0){
                        layer.alert("请选择需操作的数据");return;
                    }
                    layer.confirm('是否确定操作?', function(index){
                        let url="{:URL('community/answer/delAnswer')}";
                        let where = {id:id};
                        publicDel(table,url,where,obj,index,1);
                    });
                    break;

            };
        });

    });
</script>
</html>
